import React from 'react'
import Taro from '@tarojs/taro'
import {Swiper, SwiperItem ,Image, View} from '@tarojs/components'

class TopSwiper extends React.Component{

  constructor(){
    super(...arguments)
    this.state={
      getting:false
    }
  }

  componentWillMount(){
    // 自适应
    Taro.getSystemInfo().then(res => this.setState({
      width:res.windowWidth,
      getting:true
    }))
  }


  render(){
      return(
        this.state.getting?
          <Swiper circular indicatorDots autoplay>
              <SwiperItem>
                <Image  style={'width:'+this.state.width+'px;height: 150px;'}
                        src='http://39.106.116.133:8080/images/index/banner1.png' />
              </SwiperItem>
              <SwiperItem>
                <Image  style={'width:'+this.state.width+'px;height: 150px;'}
                        src='http://39.106.116.133:8080/images/index/banner2.png' />
              </SwiperItem>
              <SwiperItem>
                <Image  style={'width:'+this.state.width+'px;height: 150px;'}
                        src='http://39.106.116.133:8080/images/index/banner3.png' />
              </SwiperItem>
          </Swiper>
        :<View></View>
      )
    }
}
  
  export {TopSwiper}